home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS26.ADF / SoundScape / LatticeExamples / skeleton.c < prev    next >
C/C++ Source or Header  |  1989-01-26  |  3KB  |  131 lines

  1. /*    SKELETON.C    Skeleton module for Lattice C.
  2.  
  3.     (c) 1987    Todor Fay
  4. */
  5.  
  6. #include "exec/exec.h"
  7. #include "exec/types.h"
  8. #include "soundscape.h"
  9. #include "intuition/intuition.h"
  10.  
  11. /*    Images for input and output icons of the module.  */
  12.  
  13. extern struct Image *inimage, *outimage;
  14.  
  15. /*    Define your own state structure for edit routines. */
  16.  
  17. struct State {
  18.     long length;        /* Always has a length field first. */
  19.  
  20. /*    You supply remaining fields. */
  21.  
  22. };
  23.  
  24. /*    Declare a state structure. */
  25.  
  26. struct State state = { sizeof(state) - 4, };
  27.  
  28. /*    Pick an ID for your port, and a name. * /
  29.  
  30. #define PORT_ID        255
  31. #define PORT_NAME    "myportname"
  32.  
  33. /*    The id for this port, returned by AddMidiPort: */
  34.  
  35. short thisport;
  36.  
  37. /*    Base Pointers to SoundScape and Intuition */
  38.  
  39. long SoundScapeBase;
  40. long IntuitionBase;
  41.  
  42. outcode(note)
  43.  
  44. /*    This is your output routine.  It is called by the packet
  45.     router whenever it has a MIDI event for you.  Do something
  46.     with the event, then return.
  47. */
  48.  
  49. struct Note *note;
  50.  
  51. {
  52.     FreeNode(note);
  53. }
  54.  
  55. opencode(direction)
  56.  
  57. /*    Depending on the direction, open the module for operation.
  58.     Return 1 if successful, 0 if not.  
  59. */
  60.  
  61. char direction;
  62.  
  63. {
  64.     if (direction) {
  65.     /*  Code to init for sending events. */
  66.     }
  67.     else {
  68.     /*  Code to init for receiving events. */
  69.     }
  70.     return(1);
  71. }
  72.  
  73. closecode(direction)
  74.  
  75.     if (direction) {
  76.     /*  Code to close down sending events. */
  77.     }
  78.     else {
  79.     /*  Code to take care of stopping receiving events. */
  80.     }
  81.     return(1);
  82. }
  83.  
  84. editcode(direction,command,buffer);
  85.  
  86. char direction;
  87. char command;
  88. struct State *buffer;
  89.  
  90. {
  91.     switch (command) {
  92.     case USEREDIT :
  93.         if (direction) {
  94.     /*    Your edit routine for left icon here. */
  95.         }
  96.         else {
  97.     /*    Your edit routine for right icon here. */
  98.         }
  99.         break;
  100.     case SAVESTATE :
  101.     /*     Your routine to save to a file here. */
  102.     case GETSTATE :
  103.         movmem(&state,buffer,sizeof(state));
  104.         break;
  105.     case LOADSTATE :
  106.         movmem(buffer,&state,sizeof(state));
  107.         state.length = (sizeof(state) - 4);
  108.     /*    Your routine to load a file here. */
  109.         break;
  110.     case SETSTATE :
  111.         movmem(buffer,&state,sizeof(state));
  112.         state.length = (sizeof(state) - 4);
  113.         break;
  114.      }
  115. }
  116.  
  117.  
  118. main() {
  119.     IntuitionBase = OpenLibrary("intuition.library",0);
  120.     SoundScapeBase = OpenLibrary("soundscape.library",0);
  121.     if (SoundScapeBase) {
  122.     CloseLibrary(SoundScapeBase);
  123.     thisport = AddMidiPort(opencode,closecode,editcode,outcode,
  124.         &inimage,&outimage,PORT_ID,PORT_NAME);
  125.     SetTaskPri(FindTask(0),-20);
  126.     while (MidiPort(thisport)) Delay(100);
  127.     }
  128.     CloseLibrary(IntuitionBase);
  129. }
  130.